package com.example.springspidemo;

import com.example.springspidemo.config.SpringConfig;
import com.example.springspidemo.service.MessageService;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@SpringBootApplication
public class SpringSpiDemoApplication {

    public static void main(String[] args) {
        // 创建 Spring 上下文，加载配置文件
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);

        // 从上下文中获取 Bean
        MessageService helloMessageService = context.getBean("helloMessageService", MessageService.class);
        MessageService hiMessageService = context.getBean("hiMessageService", MessageService.class);

        System.out.println(helloMessageService.getMessage());
        System.out.println(hiMessageService.getMessage());
    }

}
